#pragma one
#include <mutex>

template <typename T>
class Singleton
{
public:
    static T* GetInstance()
    {
        static T instance;
        return &instance;
        // if (instance_ == nullptr)
        // {
        //     std::lock_guard<std::mutex> l(mutex_);
        //     if (instance_ == nullptr)
        //         instance_ = new T();
        // }
        // return instance_;
    }

private:
    // static T *instance_;
    // static std::mutex mutex_;

    Singleton(){};
    ~Singleton(){};
    Singleton(const Singleton &singleton) = delete;

    const Singleton &operator=(const Singleton &singleton) = delete;

    // class Delete {
	// public:
	// 	Delete(){
    //         std::cout << "singleton delte creat"  << std::endl; 
    //     }
	// 	~Delete(){
	// 		if(instance_ != nullptr){
	// 			delete instance_;
	// 			instance_ = nullptr;
    //             std::cout << "singleton delete"  << std::endl; 
	// 		}
	// 	}
	// };
	// static Delete free_; //这里需要设为静态才行 ，且需要在外部实例化 
};

// template <typename T>
// T *Singleton<T>::instance_ = nullptr;

// template <typename T>
// std::mutex Singleton<T>::mutex_;

// template <typename T>
// typename Singleton<T>::Delete Singleton<T>::free_;


